运用c++编程>>数组,指针与字符串

来源:百度知道 编辑:UC知道 时间:2024/06/05 10:25:34
编写一个函数,统计一条英文句子中字母的个数,在主程序中实现输入和输出

#include<iostream>
using namespace std;

int main()
{
char a[1000],*p;
int count=0;
p=a;
gets(a);
while(*p!='\0')
{
if((*p>='a'&&*p<='z')||((*p>='A')&&(*p<='Z')))
{
count++; p++;
}
else
p++;
}
cout<<count<<endl;
}